<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>两面翻转的盒子</title>
    <style>
      body {
        perspective: 400px;
      }

      .box {
        position: relative;
        width: 200px;
        height: 200px;
        margin: 100px auto;
        /* 让背面的紫色盒子保留立体空间 */
        transform-style: preserve-3d;
        transition: all 1s;
      }

      .box:hover {
        transform: rotateY(180deg);
      }

      .front,
      .back {
        position: absolute;
        width: 100%;
        height: 100%;
        border-radius: 50%;
        font-size: 20px;
        line-height: 200px;
        text-align: center;
      }

      .front {
        background-color: pink;
        z-index: 1;
        /* 注意  隐藏被旋转的div元素的背面*/
        backface-visibility: hidden;
      }

      .back {
        background-color: rgb(180, 226, 245);
        transform: rotateY(180deg);
      }
    </style>
  </head>

  <body>
    <div class="box">
      <div class="front">雷电将军</div>
      <div class="back">我在等你</div>
    </div>
  </body>
</html>
